#pragma once
#include "../core/base/basic_types.h"
#include "../core/input/game_pad.h"
#include "../core/input/touch_event.h"

class KAppFrame 
{
public:
	struct CanvasViewState {
		unsigned int width;
		unsigned int height;

		KVec2 viewCenter;
		float viewZoom;
	};
	
public:
	KAppFrame();
	virtual ~KAppFrame();

	static KAppFrame* GetInstance();
	
	virtual bool Init();
	virtual void Destory();
	virtual void TimeElapse(unsigned int ms);
	virtual bool Render() = 0;
	virtual void OnChangeViewPerFrame(CanvasViewState& viewState, const KRect& centerRectLimit);

	void EnableCanvasView(bool ena);
private:
	void ValidateCanvasViewSetting(KRect& centerRectLimit);

public:
	KGamePadState 			mGamePadStatus;
	KTouchEventRingBuffer	mTouchEvents;
protected:
	
	float mFPS;
	long long mTimeTicks;
	CanvasViewState		mCanvasViewState;
	KRect				mCenterRectLimit;
	KColor mBK_Color;

	

private:
	unsigned int mTimeSinceLast;
	unsigned int mFrameSinceLast;

	KVec2 mVirtualViewportSize;
	KVec2 mViewportCenter;
};